<?php

namespace App\Http\Resources\OpenShop\InvestmentPromotion;

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

class OrderManagerResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  Request  $request
     * @return array
     */
    public function toArray($request): array
    {
        return [
            "id" => $this->id,
            "mainProcessId" => $this->mainProcessId,
            "managerUid" => $this->managerUid,
            "managerName" => $this->managerName,
            "type" => $this->type,
            "description" => $this->description,
            "createdAt" => formatDate($this->createdAt->timestamp),
            "rmsUserStatus" => $this->getRmsUserStatus(),
            "hasAuth" => $this->hasAuth
        ];
    }

    /**
     * @return bool
     */
    public function getRmsUserStatus(): bool
    {
        if($this->rmsUser && $this->rmsUser->isDeleted == 0 && $this->rmsUser->status == 0){
            return true;
        }
        return false;
    }
}
